package com.ice.day726.thread;

import java.io.*;
import java.util.Scanner;

public class Main2 {


    static public int one(int n, int x) {
        int cur = 0;
        for (; n > 0; n /= 10) {
            if (n % 10 == x) {
                cur++;
            }
        }
        return cur;
    }

    static public int count(int n, int x) {
        int cur = 0;
        for (int i = 1; i <= n; i++) {
            cur += one(i, x);
        }
        return cur;
    }

    public static void main(String[] args) {
        BufferedReader br = null;
        BufferedWriter bw = null;
//        try {
//            br  = new BufferedReader(new FileReader("./count.in"));
//            String line = br.readLine();
//            String[] s = line.split(" ");
//            int n = Integer.parseInt(s[0]);
//            int x = Integer.parseInt(s[1]);
//            bw = new BufferedWriter(new FileWriter("./count.out"));
//            int count = count(n, x);
//            bw.write(count);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }finally {
//            try {
//                assert br != null;
//                br.close();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//            try {
//                assert bw != null;
//                bw.close();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }

        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] s1 = s.split(" ");
        int n = Integer.parseInt(s1[0]);
        int x = Integer.parseInt(s1[1]);
        int count = count(n, x);
        System.out.println(count);
    }
}
